package com.company.project.controller;
import com.company.project.model.URolePermission;
import com.company.project.service.URolePermissionService;
import com.company.project.core.MsgMap;
import com.company.project.core.BaseController;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

/**
* Created by generator.CodeGenerator on 2018/01/14.
*/
@Controller
@RequestMapping("/uRolePermission")
public class URolePermissionController extends BaseController{

    @Autowired
    private URolePermissionService uRolePermissionService;

    @RequestMapping("add")
    @ResponseBody
    public MsgMap add(URolePermission uRolePermission) {
        MsgMap msg = this.getMsgMap();
        uRolePermissionService.save(uRolePermission);
        return msg;
    }

    @RequestMapping("delete")
    @ResponseBody
    public MsgMap delete(URolePermission uRolePermission) {
        MsgMap msg = this.getMsgMap();
        uRolePermissionService.deleteById(uRolePermission);
        return msg;
    }

    @RequestMapping("update")
    @ResponseBody
    public MsgMap update(URolePermission uRolePermission) {
        MsgMap msg = this.getMsgMap();
        uRolePermissionService.update(uRolePermission);
        return msg;
    }

    @RequestMapping("detail")
    @ResponseBody
    public MsgMap detail(URolePermission uRolePermission) {
        MsgMap msg = this.getMsgMap();
        URolePermission uRolePermissionResult = uRolePermissionService.findById(uRolePermission);
        return msg;
    }

    @RequestMapping("list")
    @ResponseBody
    public MsgMap list(URolePermission uRolePermission , @RequestParam(defaultValue = "0") Integer page
                        , @RequestParam(defaultValue = "10") Integer size) {
        MsgMap msg = this.getMsgMap();
        List<URolePermission> list = uRolePermissionService.list( uRolePermission , page , size  );
        PageInfo pageInfo = new PageInfo(list);
        return msg;
    }
}
